
--[[
每次点击花费20X成功个人杀敌
每次失败提升2%几率


失败特殊：
本地免费
500杀敌
额外5%几率


资源：每秒木材+1
资源：攻击吸血+20%
多重：多重攻击+2
恢复：每秒恢复2%生命
速度：攻击速度+20%，冷却速度+20%
伤害：物理伤害+20%，魔法伤害+20%
输出：普攻输出+20%，技能输出+20%
大招：解锁大招

]]

ac.skill('经脉1'){
    title = '木材',
    art = [[ReplaceableTextures\CommandButtons\BTNSteelMelee.blp]],
    ['每秒木材'] = 1,
}

ac.skill('经脉2'){
    title = '资源',
    art = [[ReplaceableTextures\CommandButtons\BTNSteelMelee.blp]],
    ['每秒金币'] = 10,
}

ac.skill('经脉3'){
    title = '多重',
    art = [[ReplaceableTextures\CommandButtons\BTNSteelMelee.blp]],
    ['多重数量'] = 2,
}

ac.skill('经脉4'){
    title = '恢复',
    art = [[ReplaceableTextures\CommandButtons\BTNSteelMelee.blp]],
    ['生命百分比恢复'] = 2
}


ac.skill('经脉5'){
    title = '速度',
    art = [[ReplaceableTextures\CommandButtons\BTNSteelMelee.blp]],
    ['攻击速度'] = 20,
    ['冷却速度'] = 20,
}

ac.skill('经脉6'){
    title = '伤害',
    art = [[ReplaceableTextures\CommandButtons\BTNSteelMelee.blp]],
    ['物理伤害'] = 20,
    ['魔法伤害'] = 20,
}

ac.skill('经脉7'){
    title = '输出',
    art = [[ReplaceableTextures\CommandButtons\BTNSteelMelee.blp]],
    ['普攻输出'] = 20,
    ['技能输出'] = 20,
}
ac.skill('经脉8'){
    title = '大招',
    art = [[ReplaceableTextures\CommandButtons\BTNSteelMelee.blp]],
}

local list = {}
for a=1,8 do
    local name = ('经脉%s'):format(a)
    local data = {
        tip = [[属性：|n'base_tip'|n|n|cff999999每次兑换失败提升2%成功几率|n每次兑换成功提升其余10点杀敌需求|r]],
        get_food = function(self)
            local unit = self.owner
            local player = unit.owner
            if player then
                return 20 + 10 * player:get_data('杀敌兑换-成功次数',0)
            end
        end,
        get_odds = function(self)
            local unit = self.owner
            local player = unit.owner
            if player then
                return 20 + player:get_data('杀敌兑换-成功几率',0)
            end
        end,
        on_add = function(self)
            local unit = self.owner
            self.show_cd_num = self.title
            self.base_tip = self.base_tip or atts_tip(self)

            local odds = self:get_odds()
            unit.shop_title = ('成功几率：%s%%'):format(odds)
        end,
        on_sell = function(self,hero,player)
            local unit = self.owner
            local hero = player.hero
            local odds = self:get_odds()
            show_skill_tip(player,self,'刷新')
            if odd_run(odds) then
                local count = player:get_data('杀敌兑换-成功次数',0) + 1
                if count<=4 and math.random(100)<=1 then
                    player:send_msg('天命之子！完成所有兑换')
                elseif player:get_data('杀敌兑换-成功几率',0)==0 then
                    player:send_msg('运气爆棚！额外获得杀敌+100')
                    player:add('杀敌',100)
                end
                player:set_data('杀敌兑换-成功几率',0)
                player:set_data('杀敌兑换-成功次数',count)
                LoadItemSX(hero,self,1)
                self:notify('on_run',hero)
                self:remove()
                if count==8 then
                    unit:remove()
                end
            else
                local ex_odds = 2
                if math.random(100)<=10 then
                    local name = table.random({'再来一次','不要灰心','欧皇附体','天降横财'})
                    if name=='再来一次' then
                        player:add('杀敌',self:get_food())
                    elseif name=='不要灰心' then
                        ex_odds = 5
                        player:send_msg('不要灰心！成功几率+5%')
                    elseif name=='欧皇附体' then
                        ex_odds = odds
                        player:send_msg('欧皇附体！几率翻倍')
                    elseif name=='天降横财' then
                        player:add('杀敌',200)
                        player:send_msg('天降横财！杀敌+200')
                    end
                end
                player:set_data('杀敌兑换-成功几率',player:get_data('杀敌兑换-成功几率',0) + ex_odds)
            end
            
            local odds = self:get_odds()
            unit.shop_title = ('成功几率：%s%%'):format(odds)
        end,
    }

    ac.lni('skill',name,data)
end

        --兑换

ac.skill('杀敌兑换设置'){
    on_add = function(self)
        self:remove()
        local unit = self.owner
        shop_add_panel(unit)
        for a=1,8 do
            local name = ('经脉%s'):format(a)
            unit:add_skill(name,'英雄')
        end
    end
}